import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);
let store = new Vuex.Store({
  // 1. state
  state: {
    otcData: ""
  },

  // // 2. getters
  getters: {
    // 参数列表state指的是state数据
    getData(state) {
      return state.otcData;
    }
  },
  // 3. actions
  actions: {
    setData({ commit, state }, name) {
      commit("setCon", name);
    }
  },
  // 4. mutations
  mutations: {
    // state指的是state的数据
    setCon(state, name) {
      state.otcData = name;//将传参设置给state的city
    }
  }
});
//使用方法
// this.$store.dispatch("setData","asdfasdfas") 设置
// console.log( this.$store.getters.getData) //获取
export default store;